//package com.delivery.deliverysystem.util;
//
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang.StringUtils;
//import org.lionsoul.ip2region.DataBlock;
//import org.lionsoul.ip2region.DbConfig;
//import org.lionsoul.ip2region.DbSearcher;
//import org.lionsoul.ip2region.Util;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//
//import javax.servlet.http.HttpServletRequest;
//import java.io.File;
//import java.io.InputStream;
//
//@Slf4j
//public class IpUtils {
//
//    /**
//     * 本地环回地址
//     */
//    private static final String LOCAL_IP = "127.0.0.1";
//
//    /**
//     * 未知
//     */
//    private static final String UNKNOWN = "unknown";
//
//    public static String getIpAddr(HttpServletRequest request) {
//
//        if (request == null) {
//            return UNKNOWN;
//        }
//
//        String ip = request.getHeader("x-forwarded-for");
//        if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
//            ip = request.getHeader("Proxy-Client-IP");
//        }
//        if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
//            ip = request.getHeader("X-Forwarded-For");
//        }
//        if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
//            ip = request.getHeader("WL-Proxy-Client-IP");
//        }
//        if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
//            ip = request.getHeader("X-Real-IP");
//        }
//
//        if (StringUtils.isBlank(ip) || UNKNOWN.equalsIgnoreCase(ip)) {
//            ip = request.getRemoteAddr();
//        }
//
//        return "0:0:0:0:0:0:0:1".equals(ip) ? LOCAL_IP : ip;
//    }
//
//}
